package com.orifine.orm.type;


import com.orifine.orm.Type;
import com.orifine.orm.model.ColumnModel;

public class Char extends Type {
	private String value;
	private Type typeAnnotation;
	
	Char() {
	}
	
	public Char(String value){
		set(value);
	}
	
	private void set(String value){
		this.value = value;
	}
	
	public String valueString(){
		return value.trim();
	}

	@Override
	public String getScriptValue(ColumnModel column) {
		if(value == null) return "NULL";
		else return filterQuote(value);
		
	}

	@Override
	public String getScriptType(ColumnModel column) {
		String lengthString = "";
		String typeString = "CHAR";
		if(typeAnnotation != null){
			if(column.getLength().getValue() != 0){
				lengthString = "("+column.getLength().getValue()+")";
			}
		}
		return typeString + lengthString;
	}
}
